﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace BLO
{
    /// <summary>
    /// Summary description for Module
    /// </summary>
    public class Module
    {
        DTO.Module info;
        DAO.Module moduleDAO;

        public Module()
        {
            this.moduleDAO = new DAO.Module();
            this.info = new DTO.Module();
        }

           /// <summary>
        /// Module Information.
        /// </summary>
        public DTO.Module Info
        {
            get { return this.info; }
            set { this.info = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="ID"></param>
        public static Module GetModule(String ID)
        {
            DAO.Module moduleDAO = new DAO.Module();
            Module module = new  Module();
            module.Info = moduleDAO.GetModule(ID);
            return module;
        }

        /// <summary>
        /// Insert Module information to database.
        /// </summary>
        public int Insert()
        {
            return moduleDAO.InsertModule(this.info);
        }

        /// <summary>
        /// Update information to database.
        /// </summary>
        public int Update()
        {
            return moduleDAO.UpdateModule(this.info);
        }

        /// <summary>
        /// Re-get all information from database about this Modules.
        /// </summary>
        public void Refresh()
        {
            this.info = moduleDAO.GetModule(this.info.ID.ToString());
        }

        /// <summary>
        /// Delete this news from database.
        /// </summary>
        public int Delete()
        {
            return moduleDAO.DeleteModule(this.info);
        }
    }
}